package cloud.xlh.my_system.service.impl;

import cloud.xlh.my_system.common.Result;
import cloud.xlh.my_system.mapper.EmpMapper;
import cloud.xlh.my_system.pojo.Emp;
import cloud.xlh.my_system.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/5/27 15:23
 * @ Description:
 */
@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public String updateSalary(String id , String add) throws Exception {
        Emp emp = empMapper.findEmpById();
        String newSalary = String.valueOf(Integer.parseInt(emp.getSalary()) + Integer.parseInt(add));

        empMapper.updateSalary( new Emp()
                .setId(id)
                .setSalary(newSalary));
        return "更新成功";
    }
}
